package com.login;

import java.io.IOException;
import java.io.Writer;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Loginservlet extends HttpServlet {
	
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		System.out.println("something added...");
		System.out.println("something added for the second time");
		System.out.println("something added for the third time"); 
		String uname=request.getParameter("username");
		String paswd=request.getParameter("password");
		String msg=null;
		
		
		
		RequestDispatcher rqd= null;
		
		Writer out = response.getWriter();
		msg="<h1> Login success";			
		out.write(msg);
		if(uname.equals(paswd)){
			
			
			rqd= request.getRequestDispatcher("/WEB-INF/Success.html");
			rqd.forward(request, response);
			
				
		}else{
			rqd= request.getRequestDispatcher("/WEB-INF/Failure.html");
			rqd.forward(request, response);
		}
		msg="<h1> Login success";			
		out.write(msg);
		
		
		
	}

}
